package jacob;

import java.sql.Blob;

import com.idTech.iDTechModBaseJacob;

import net.minecraft.block.Block;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.Entity;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import cpw.mods.fml.common.registry.GameRegistry;

public class util 
{
	/*
	 * A static function called on "load"
	 * Loads all initial recipes
	**/
public static void recipies()
	{
	//crafting recipes
	
	ItemStack dirt = new ItemStack (Block.dirt);
	ItemStack diamondblock = new ItemStack (Block.blockDiamond, 64);
	ItemStack cobblestone= new ItemStack (Block.cobblestone);
	ItemStack GoldenApple= new ItemStack (Item.appleGold);
	ItemStack stick= new ItemStack (Item.stick);
	ItemStack expBottle= new ItemStack (Item.expBottle, 64);
	ItemStack Stone= new ItemStack (Block.stone);
	ItemStack EnchantTable= new ItemStack (Block.enchantmentTable);
	ItemStack bookShelf= new ItemStack (Block.bookShelf, 64);
	ItemStack enderpearl= new ItemStack (Item.enderPearl, 64);
	ItemStack bow= new ItemStack (Item.bow);
	ItemStack arrow= new ItemStack (Item.arrow, 64);
    ItemStack torch= new ItemStack (Block.torchWood, 64);
    ItemStack ladder= new ItemStack (Block.ladder);
    ItemStack plank= new ItemStack (Block.planks);
    ItemStack lever= new ItemStack (Block.lever);
    ItemStack piston= new ItemStack (Block.pistonStickyBase);
    ItemStack Glass= new ItemStack (Block.glass);
    ItemStack Beacon= new ItemStack (Block.beacon);
    ItemStack CommandBlock= new ItemStack (Block.commandBlock);
    ItemStack LightningSword= new ItemStack (iDTechModBaseJacob.Lighting_Sword);
    ItemStack Anvil= new ItemStack (Block.anvil);
    ItemStack MobSpawner= new ItemStack (Block.mobSpawner);
    ItemStack FireSword=new ItemStack (iDTechModBaseJacob.Lava_Sword);
    ItemStack Grass= new ItemStack (Block.grass);
    ItemStack stone= new ItemStack (Block.stone);
    ItemStack LavaBow= new ItemStack (iDTechModBaseJacob.Lava_Bow);
    ItemStack string= new ItemStack (Item.silk);
    ItemStack lavabucket= new ItemStack (Item.bucketLava);
    ItemStack waterbucket= new ItemStack (Item.bucketWater);
    ItemStack WaterBow= new ItemStack (iDTechModBaseJacob.Water_Bow);
    ItemStack MobBow= new ItemStack (iDTechModBaseJacob.Mob_Bow);
    ItemStack wheat= new ItemStack (Item.wheat);
    ItemStack fence= new ItemStack (Block.fence, 64);
    ItemStack fencegate= new ItemStack (Block.fenceGate);
    ItemStack carrot= new ItemStack (Item.carrot);
    ItemStack portal= new ItemStack (Block.portal, 64);
    ItemStack netherrack= new ItemStack (Block.netherrack);
    ItemStack skull= new ItemStack (Item.skull);
    ItemStack mobegg= new ItemStack (iDTechModBaseJacob.WackyMonsterPlacer);
    ItemStack Jspawner= new ItemStack (iDTechModBaseJacob.Spawnerjacob);
    ItemStack Basewand= new ItemStack (iDTechModBaseJacob.QuickBaseWand);
    ItemStack jailbars= new ItemStack (Block.fenceIron, 64);
    ItemStack TeleportationWand = new ItemStack (iDTechModBaseJacob.Pig_Wand);
    ItemStack seeds= new ItemStack (Item.seeds);
    ItemStack firewand= new ItemStack (iDTechModBaseJacob.Fire_Wand);
    LightningSword.addEnchantment(Enchantment.knockback, 50);
    ItemStack bone= new ItemStack (Item.bone, 64);
    ItemStack dragonegg= new ItemStack (Block.dragonEgg);
    ItemStack potato= new ItemStack (Item.potato);
    ItemStack redstone= new ItemStack (Item.redstone, 64);
    ItemStack redstonerepeater= new ItemStack (Item.redstoneRepeater);
    ItemStack redstonelamp= new ItemStack (Block.redstoneLampIdle);
    ItemStack emeraldhelmet= new ItemStack (iDTechModBaseJacob.helmetEmerald);
    emeraldhelmet.addEnchantment(Enchantment.projectileProtection, 20);
    emeraldhelmet.addEnchantment(Enchantment.protection, 20);
    ItemStack emeraldchestplate= new ItemStack (iDTechModBaseJacob.chestplateEmerald);
    emeraldchestplate.addEnchantment(Enchantment.projectileProtection, 20);
    emeraldchestplate.addEnchantment(Enchantment.protection, 20);
    ItemStack emeraldleggings= new ItemStack (iDTechModBaseJacob.legsEmerald);
    emeraldleggings.addEnchantment(Enchantment.projectileProtection, 20);
    emeraldleggings.addEnchantment(Enchantment.protection, 20);
    ItemStack emeraldboots= new ItemStack (iDTechModBaseJacob.bootsEmerald);
    emeraldboots.addEnchantment(Enchantment.projectileProtection, 20);
    emeraldboots.addEnchantment(Enchantment.protection, 20);
    emeraldboots.addEnchantment(Enchantment.featherFalling, 20);
    ItemStack emerald= new ItemStack (Item.emerald, 64);
    //ItemStack adds Item
    //GameRegistry adds crafting recipe
    GameRegistry.addShapelessRecipe(emerald, diamondblock);
    GameRegistry.addShapedRecipe(emeraldhelmet, "   ", "xxx", "x x", 'x', emerald);
    GameRegistry.addShapedRecipe(emeraldchestplate, "x x", "xxx", "xxx", 'x', emerald);
    GameRegistry.addShapedRecipe(emeraldleggings, "xxx", "x x", "x x", 'x', emerald);
    GameRegistry.addShapedRecipe(emeraldboots, "   ", "x x", "x x", 'x', emerald);
    GameRegistry.addShapedRecipe(piston, "xxx", "   ", "xxx", 'x', cobblestone);
    GameRegistry.addShapelessRecipe(redstonerepeater, redstone);
    GameRegistry.addShapelessRecipe(redstonelamp, redstonerepeater);
    GameRegistry.addShapedRecipe(redstone, "x  ", "x  ", "x  ", 'x', stick);
    GameRegistry.addShapedRecipe(Basewand, "x  ", "x  ", "x  ", 'x', redstone);
    GameRegistry.addShapedRecipe(jailbars, "xxx", "xxx", "xxx", 'x', skull);
    GameRegistry.addShapelessRecipe(potato, carrot);
    GameRegistry.addShapedRecipe(Jspawner, "xxx", "xxx", "xxx", 'x', jailbars);
    GameRegistry.addShapelessRecipe(bone, dragonegg);
    GameRegistry.addShapelessRecipe(lavabucket, waterbucket);
    GameRegistry.addShapedRecipe(firewand, " x ", " y ", " z ", 'x', seeds, 'y', lavabucket, 'z', stick);
    GameRegistry.addShapedRecipe(TeleportationWand, " x ", " x ", " y ", 'x', enderpearl, 'y', stick);
    GameRegistry.addShapelessRecipe(mobegg, skull);
    GameRegistry.addShapelessRecipe(skull, fence);
    GameRegistry.addShapelessRecipe(arrow, netherrack);
    GameRegistry.addShapedRecipe(fence, "x  ", "   ", "  x", 'x', dirt);
    GameRegistry.addShapedRecipe(fencegate, "  x",  "   ", "x  ", 'x', dirt);
    GameRegistry.addShapedRecipe(portal, "x  ", "   ", "x  ", 'x', dirt);
    GameRegistry.addShapedRecipe(carrot, " x ", "   ", " x ", 'x', dirt);
    GameRegistry.addShapedRecipe(MobBow, "xy ", "xzy", "xy ", 'x', string, 'y', stick, 'z', GoldenApple);
    GameRegistry.addShapedRecipe(WaterBow, "xy ", "xzy", "xy ", 'x', string, 'y', stick, 'z', waterbucket);
    GameRegistry.addShapedRecipe(LavaBow, "xy ", "xzy", "xy ", 'x', string, 'y', stick, 'z', lavabucket);
    GameRegistry.addShapedRecipe(Grass, "x  ", "x  ", "   ", 'x', dirt);
    GameRegistry.addShapedRecipe(FireSword, "x  ", "x  ", "x  ", 'x', diamondblock);
    GameRegistry.addShapedRecipe(Anvil, "xxx", "xxx", "xxx", 'x', cobblestone);
    GameRegistry.addShapedRecipe(LightningSword, " x ", " x ", " x ", 'x', diamondblock);
    GameRegistry.addShapedRecipe(expBottle, "xxx", "xxx", "xxx", 'x', Glass);
    GameRegistry.addShapedRecipe(CommandBlock, "xxx", "xxx", "xxx", 'x', diamondblock);
    GameRegistry.addShapedRecipe(Beacon, "xxx", "xxx", "xxx", 'x', dirt);
    GameRegistry.addShapelessRecipe(bow, dirt);
    GameRegistry.addShapelessRecipe(GoldenApple, cobblestone);
    GameRegistry.addRecipe(EnchantTable, "xxx", "x x", "xxx", 'x', dirt);
    GameRegistry.addRecipe(bookShelf, "xxx", " x ", "xxx", 'x', dirt);
    GameRegistry.addRecipe(enderpearl, "  x", "  x", "  x", 'x', dirt);
    GameRegistry.addShapelessRecipe(torch, ladder);
    GameRegistry.addShapelessRecipe(lever, enderpearl);
    GameRegistry.addShapelessRecipe(Glass, stick);
    GameRegistry.addShapedRecipe(MobSpawner, "x  ", "   ", "x  ", 'x', diamondblock);
    GameRegistry.addSmelting(Block.dirt.blockID, diamondblock, 1000000000);
	}

	public static Vec3 placeInFrontOfEntity(Entity _entity, float meters )
	{
	        Vec3 ret = Vec3.createVectorHelper(0,0,0);
	        ret.xCoord = _entity.posX;
	        ret.yCoord = _entity.posY;
	        ret.zCoord = _entity.posZ;
	        float yaw = _entity.rotationYaw - 90;
	        ret.xCoord -= ((double)(MathHelper.cos(yaw/ 180.0F * (float)Math.PI))) * meters;
	        ret.zCoord -= ((double)(MathHelper.sin(yaw/ 180.0F * (float)Math.PI))) * meters;
	        return ret;
	}
	
	public static Vec3 placeInRandomDir(int x, int y, int z, float meters )
	{
	        Vec3 ret = Vec3.createVectorHelper(0,0,0);
	        ret.xCoord = x;
	        ret.yCoord = y;
	        ret.zCoord = z;
	        float yaw = (float)Math.random() * 360;
	        ret.xCoord -= ((double)(MathHelper.cos(yaw/ 180.0F * (float)Math.PI))) * meters;
	        ret.zCoord -= ((double)(MathHelper.sin(yaw/ 180.0F * (float)Math.PI))) * meters;
	        return ret;
	}
}
